package com.example.rwq_test.designParttern.multiThread.future;

/**
 * 提货单
 *
 * @author renweiqiang
 * @version 1.0.0
 * @createTime 2022/11/15
 */
public class FutureData implements Data{
    private RealData realData = null;
    private boolean ready = false;

    @Override
    public synchronized String getContent() {
        while (!ready) {
            try {
                wait();
            } catch (InterruptedException e) {

            }
        }
        return realData.getContent();
    }

    public synchronized void setRealData(RealData realData) {
        if (ready) {
            return;
        }
        this.realData = realData;
        ready = true;
        notifyAll();
    }

}
